package com.dhj.methodsTest;

import com.dhj.streamTest.entity.Author;

import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;

import static com.dhj.streamTest.entity.AuthorList.getAuthors;

public class Demo2 {

    public static void main(String[] args) {
        List<Author> authors = getAuthors();

        authors.stream().distinct()
                .map(author -> author.getAge())
                .map(new Function<Integer, String>() {
                    @Override
                    public String apply(Integer age) {
                        return String.valueOf(age);
                    }
                })
                .forEach(name -> System.out.println(name));

        System.out.println("------------------------------");


        authors.stream().distinct()
                .map(author -> author.getAge())
                .map(age -> String.valueOf(age))
                .forEach(name -> System.out.println(name));

        System.out.println("------------------------------");

        authors.stream().distinct()
                .map(Author::getAge)
                .map(String::valueOf)
                .forEach(System.out::println);




    }
}
